﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com

using System.IO;
namespace ImageAppViewModels
{
    public static class FilePaths
    {
        public static string _pathToExaminePath = @"c:\paths.dat";
        public static string _settingsPath = @"c:\settings.dat";
        public static string _filterSave = @"c:\FilterCollectionNames.dat";
        public static string _filterSaveHardcoded = @"c:\HardcodedFilters.dat";
        public static string _filterBlur1Save = @"c:\filtersBlur1.dat";
        public static string _filterBlur2Save = @"c:\filtersBlur2.dat";
        public static string _filterCompareSave = @"c:\filtersCompare.dat";
        public static string _metaDataFilePath = @"c:\meta.dat";
        public static string _groupsFilePath = @"c:\groups.dat";
        public static string _fileImageGroupsFilePath = @"c:\fileimagegroups.dat";
        public static string _pluginsDir = @"C:\Plugins\";

        //public static readonly string[] PathsToExamine = new string[] {             
        //    @"C:\Users\Owen\Desktop\FamilyAndFriends\Pictures\108_PANA",
        //    @"C:\Users\Owen\Desktop\FamilyAndFriends\Pictures\109_PANA",
        //};

        public static void DeleteAll()
        {
            DeleteWithBackup(_pathToExaminePath);
            DeleteWithBackup(_settingsPath);
            DeleteWithBackup(_filterSave);
            DeleteWithBackup(_filterSaveHardcoded);
            DeleteWithBackup(_filterBlur1Save);
            DeleteWithBackup(_filterBlur2Save);
            DeleteWithBackup(_filterCompareSave);
            DeleteWithBackup(_metaDataFilePath);
            DeleteWithBackup(_groupsFilePath);
        }

        public static void DeleteWithBackup(string fileName)
        {
            try
            {
                if (File.Exists(fileName))
                {
                    SaveToBackup(fileName);
                    File.Delete(fileName);
                }
            }
            catch
            {
            }
        }

        public static void SaveToBackup(string fileName)
        {
            var bytes = File.ReadAllBytes(fileName);
            File.WriteAllBytes(fileName + ".bak", bytes);
        }
    }
}
